<template>
  <div class="box">
    <div id="container"></div>
  </div>
</template>

<script>
import { location } from "@/assets/javascript/map.js";
export default {
  mounted() {
    this.getCityInfo();
  },
  methods: {
    // 获取定位信息精确到市
    getCityInfo() {
      let geolocation = location.initMap("container"); //定位
      geolocation.getCityInfo((status, result) => {
        this.cityInfo = result.city;
        console.log(status);
        console.log(result);
        this.$emit("getCityInfo", result.city);
      });
    }
  }
};
</script>
